﻿




//angular.module('IGIS.directives', [])
  
var app = angular.module('IGIS', []);

var url = '/Hetz/api/Polygon/';
app.factory('PolygonFactory', function ($http, $location) {
    return {
        getPolygon: function (id) {
                
            return $http.get(url + '/' + id);
           
        },
        addPolygon: function (customer) {
            return $http.post(url, customer);
        },
        deletePolygon: function (customer) {
            return $http.delete(url + customer.CustomerID);
        },
        updatePolygon: function (polygon) {
            return $http.put(url + polygon.PolygonID, polygon);
        }
    };
});
app.directive('datepicker', function ($parse) {
    var directiveDefinitionObject = {
        restrict: 'A',
        link: function postLink(scope, iElement, iAttrs) {
            iElement.datepicker({
                dateFormat: 'yy-mm-dd',
                onSelect: function (dateText, inst) {
                    scope.$apply(function (scope) {
                        $parse(iAttrs.ngModel).assign(scope, dateText);
                    });
                }
            });
        }
    };
    return directiveDefinitionObject;
});



function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
    return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
